package com.hefei.garden.config.exception;

import com.hefei.garden.dto.response.AppCode;
import com.hefei.garden.dto.response.StatusCode;
import lombok.Getter;

/**
 * @author: devil
 * @Date: 2022/7/21 21
 * @Description:
 */
@Getter
public class ApiException extends RuntimeException {
    private final int code;
    private final String msg;

    public ApiException(StatusCode statusCode, String message) {
        // message用于用户设置抛出错误详情，例如：当前价格-5，小于0
        super(message);
        // 状态码
        this.code = statusCode.getCode();
        // 状态码配套的msg
        this.msg = statusCode.getMsg();
    }

    public ApiException(String message) {
        super(message);
        this.code = AppCode.APP_ERROR.getCode();
        this.msg = AppCode.APP_ERROR.getMsg();
    }

}
